package com.dianrui.moonfire.activity;

import android.view.View;
import android.widget.TextView;

import com.blankj.utilcode.util.SPUtils;
import com.dianrui.moonfire.R;
import com.dianrui.moonfire.bean.NewMobile;
import com.dianrui.moonfire.util.NoDoubleClickUtils;
import com.dianrui.moonfire.util.StringUtils;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.OnClick;
/**
 * Description:手机号
 * User: luoziyin
 * Date: 2020-8-17
 */
public class ShowMobileActivity extends BaseActivity {
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.mobile)
    TextView mobile;

    @Override
    public int getContentViewId() {
        return R.layout.show_mobile;
    }

    @Override
    public void initView() {
        customInit(true);
        title.setText(getString(R.string.mobile));
        if(!StringUtils.isEmpty(SPUtils.getInstance().getString("mobile")) && SPUtils.getInstance().getString("mobile").length() > 6 ){
            StringBuilder sb  =new StringBuilder();
            for (int i = 0; i < SPUtils.getInstance().getString("mobile").length(); i++) {
                char c = SPUtils.getInstance().getString("mobile").charAt(i);
                if (i >= 3 && i <= 6) {
                    sb.append('*');
                } else {
                    sb.append(c);
                }
            }
           mobile.setText(sb.toString());
        }

    }

    @Override
    public void initData() {

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(NewMobile newMobile) {
        mobile.setText(newMobile.number);
    }


    @OnClick({R.id.back, R.id.change})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.change:
                JumpActivitys(ShowMobileModiftyActivity.class);
                break;
                default:
                    break;
        }
    }
}
